<?php

/*
 * Treasure -3+$
 *
 * Worth 1$
 * 
 * When you buy this, you may overpay for it. 
 * If you do, gain a silver per $1 you overpaid
 * 
 */

class Masterpiece extends Card implements iKingdom, iTreasure, iGuilds {

    public function __construct() {
        parent::__construct("Masterpiece", 3);
        $this->value = new Price(1);
        $this->undoPlay = false;
        $this->undoBuy = false;
    }

    public function autoPlayNum(Game $game) {
        return 5;
    }

    public function getDescription() {
        return array(
            "Worth 1$",
            "When you buy this, you may overpay for it. ",
            "If you do, gain a silver per $1 you overpaid");
    }

    public function buy(Game $game) {
         $overpay = $game->getOverpayAmount($this->getValue());
         
         $silvers = array();
         $temp_silver = new Silver();
         
         for ($i = 0; $i < $overpay; $i++) {
            $new_silver = $game->moveCardFromPileToPile($temp_silver,BoardCards, DiscardPile);
            if ($new_silver) {
                $silvers[] = $new_silver;
            }
         }
         ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($silvers), "gains ".ScreenDisplay::$LMSG);
    }

}

?>